package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {

    //删除给定ID的商品
    @Delete("delete from user where id=#{id}")
    public int deleteUser(int id);

    @Insert("INSERT INTO USER(u_id,u_name,u_sex,u_phone,u_password,u_email) VALUE(#{uid},#{name},#{sex},#{phone},#{password},#{email})")
    public int registerUser(@Param("uid")int uid,@Param("name") String name, @Param("sex") String sex,
                            @Param("phone") String phone, @Param("password") String password, @Param("email") String email);

    //根据用户名和密码查询用户
    @Select("SELECT u_id,u_name FROM USER WHERE u_name =#{username} and u_password = #{password}")
    User SelectUser(@Param("username") String username, @Param("password") String password);

    //根据用户名查询用户
    @Select("SELECT u_id,u_name FROM USER WHERE u_name =#{name}")
    User SelectUserByName(@Param("name") String name);

    //查找用户uid的最大值
    @Select("select max(u_id) from user")
    int SelectMaxuId();

}
